app.controller('commonController',function ($scope){

//分页控件配置,itemsPerPage 每页记录数 perPageOptions 每页记录数可选项 onChange 页码发生改变时触发这个函数
    $scope.paginationConf = {
        currentPage: 1,
        totalItems: 10,
        itemsPerPage: 10,
        perPageOptions: [10, 20, 30, 40, 50],
        //刚进入本页面，页面从没有变为 1，onChange 也发生了改变
        onChange: function () {
            $scope.reloadList();
        }
    };

//重新加载列表
    $scope.reloadList = function () {
        $scope.search($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);

    }

//选中的要删除的
    $scope.selectedIds = [];
    $scope.updateSelectedId = function ($event, id) {
        if ($event.target.checked) {
            $scope.selectedIds.push(id);
        } else {
            var idx = $scope.selectedIds.indexOf(id);
            $scope.selectedIds.splice(idx, 1);
        }
    }

    //判断集合中是否有某个元素
    $scope.isAttributeInList=function (list,key,value) {
        for (var i=0; i<list.length;i++){
            if (list[i][key]==value){
                return list[i];
            }
        }
        return null;
    }
});